const ToggleComponent = {
    bootstrap: () => window.KTToggle.createInstances(),
    reinitialization: () => window.KTToggle.createInstances(),
    createInstance: (selector) => window.KTToggle.createInstances(selector)
}

const MenuComponent = {
    bootstrap: () => {
        window.KTMenu.createInstances()
        window.KTMenu.initGlobalHandlers()
    },
    reinitialization: () => window.KTMenu.createInstances(),
    createInstance: (selector) => window.KTMenu.createInstances(selector),
    hideDropdowns: (skip) => window.KTMenu.hideDropdowns(skip)
}

const ScrollComponent = {
    bootstrap: () => {
        window.KTScroll.createInstances()
        window.KTScroll.initGlobalHandlers()
    },
    reinitialization: () => window.KTScroll.createInstances(),
    createInstance: (selector) => window.KTScroll.createInstances(selector),
    updateAll: () => {
        const elements = document.body.querySelectorAll('[data-kt-scroll="true"]')
        elements.forEach((element) => {
            const instance = window.KTScroll.getInstance(element)
            if (instance) {
                instance.update()
            }
        })
    }
}

const DrawerComponent = {
    bootstrap: () => {
        window.KTDrawer.createInstances()
        window.KTDrawer.initGlobalHandlers()
        window.KTDrawer.handleShow()
        window.KTDrawer.handleDismiss()
    },
    reinitialization: () => {
        window.KTDrawer.createInstances()
        window.KTDrawer.hideAll()
        window.KTDrawer.updateAll()
        window.KTDrawer.handleShow()
        window.KTDrawer.handleDismiss()
    },
    createInstance: (selector) => window.KTDrawer.createInstances(selector)
}

const ScrollTopComponent = {
    bootstrap: () => window.KTScrolltop.createInstances(),
    reinitialization: () => window.KTScrolltop.createInstances(),
    createInstance: (selector) => window.KTScrolltop.createInstances(selector)
}

export {
    ToggleComponent,
    MenuComponent,
    ScrollComponent,
    DrawerComponent,
    ScrollTopComponent
}
